home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / C ++ / Snippets / MMapp / PP Basic Starter.cp < prev    next >
Encoding:
Text File  |  1996-09-04  |  3.8 KB  |  148 lines  |  [TEXT/CWIE]

  1. // ===========================================================================
  2. //    PP Basic Starter.cp         ©1994-1996 Metrowerks Inc. All rights reserved.
  3. // ===========================================================================
  4. //
  5. //    This file contains the starter code for a basic PowerPlant application
  6.  
  7. #include "PP Basic Starter.h"
  8.  
  9. #include <LGrowZone.h>
  10. #include <LWindow.h>
  11. #include <PP_Messages.h>
  12. #include <PP_Resources.h>
  13. #include <PPobClasses.h>
  14. #include <UDrawingState.h>
  15. #include <UMemoryMgr.h>
  16. #include <URegistrar.h>
  17. #include <LEditField.h>
  18.  
  19. // put declarations for resource ids (ResIDTs) here
  20.  
  21. const ResIDT    window_Sample        = 1;    // EXAMPLE
  22.  
  23.  
  24. // ===========================================================================
  25. //        • Main Program
  26. // ===========================================================================
  27.  
  28. void main(void)
  29. {
  30.                                     // Set Debugging options
  31.     SetDebugThrow_(debugAction_Alert);
  32.     SetDebugSignal_(debugAction_Alert);
  33.  
  34.     InitializeHeap(3);                // Initialize Memory Manager
  35.                                     // Parameter is number of Master Pointer
  36.                                     //   blocks to allocate
  37.     
  38.                                     // Initialize standard Toolbox managers
  39.     UQDGlobals::InitializeToolbox(&qd);
  40.     
  41.     new LGrowZone(20000);            // Install a GrowZone function to catch
  42.                                     //    low memory situations.
  43.  
  44.     CPPStarterApp    theApp;            // replace this with your App type
  45.     theApp.Run();
  46. }
  47.  
  48.  
  49. // ---------------------------------------------------------------------------
  50. //        • CPPStarterApp             // replace this with your App type
  51. // ---------------------------------------------------------------------------
  52. //    Constructor
  53.  
  54. CPPStarterApp::CPPStarterApp()
  55. {
  56.     // Register functions to create core PowerPlant classes
  57.     
  58.     RegisterAllPPClasses();
  59. }
  60.  
  61.  
  62. // ---------------------------------------------------------------------------
  63. //        • ~CPPStarterApp            // replace this with your App type
  64. // ---------------------------------------------------------------------------
  65. //    Destructor
  66. //
  67.  
  68. CPPStarterApp::~CPPStarterApp()
  69. {
  70. }
  71.  
  72. // ---------------------------------------------------------------------------
  73. //        • StartUp
  74. // ---------------------------------------------------------------------------
  75. //    This function lets you do something when the application starts up
  76. //    without a document. For example, you could issue your own new command.
  77.  
  78. void
  79. CPPStarterApp::StartUp()
  80. {
  81.     ObeyCommand(cmd_New, nil);        // EXAMPLE, create a new window
  82. }
  83.  
  84. // ---------------------------------------------------------------------------
  85. //        • ObeyCommand
  86. // ---------------------------------------------------------------------------
  87. //    Respond to commands
  88.  
  89. Boolean
  90. CPPStarterApp::ObeyCommand(
  91.     CommandT    inCommand,
  92.     void        *ioParam)
  93. {
  94.     Boolean        cmdHandled = true;
  95.  
  96.     switch (inCommand) {
  97.     
  98.         // Deal with command messages (defined in PP_Messages.h).
  99.         // Any that you don't handle will be passed to LApplication
  100.              
  101.         case cmd_New:
  102.                                         // EXAMPLE, create a new window
  103.             LWindow        *theWindow;
  104.             theWindow = LWindow::CreateWindow(window_Sample, this);    
  105.             theWindow->Show();
  106.             break;
  107.  
  108.  
  109.  
  110.         default:
  111.             cmdHandled = LApplication::ObeyCommand(inCommand, ioParam);
  112.             break;
  113.     }
  114.     
  115.     return cmdHandled;
  116. }
  117.  
  118. // ---------------------------------------------------------------------------
  119. //        • FindCommandStatus
  120. // ---------------------------------------------------------------------------
  121. //    This function enables menu commands.
  122. //
  123.  
  124. void
  125. CPPStarterApp::FindCommandStatus(
  126.     CommandT    inCommand,
  127.     Boolean        &outEnabled,
  128.     Boolean        &outUsesMark,
  129.     Char16        &outMark,
  130.     Str255        outName)
  131. {
  132.  
  133.     switch (inCommand) {
  134.     
  135.         // Return menu item status according to command messages.
  136.         // Any that you don't handle will be passed to LApplication
  137.  
  138.         case cmd_New:                    // EXAMPLE
  139.             outEnabled = true;            // enable the New command
  140.             break;
  141.  
  142.         default:
  143.             LApplication::FindCommandStatus(inCommand, outEnabled,
  144.                                                 outUsesMark, outMark, outName);
  145.             break;
  146.     }
  147. }
  148.